import 'package:yqmssa_app/request/http_path.dart';
import 'package:yqmssa_app/request/my_request.dart';

class ChatMethods {
  ChatMethods._();

  ///登录Im
  static Future<ImGetSigDataModel> login() async {
    final res = await MyRequest().dioReq(HttpPath.tencentChatGetSig);
    return ImGetSigDataModel.fromJson(res["data"]);
  }

  ///获取第一条消息
  static Future sendMessage(String serviceId) async {
    final data = {
      'service_id': serviceId,
    };
    final res = await MyRequest().dioReq(HttpPath.userApplyMessage, data: data);
    return res;
  }
}

class ImGetSigDataModel {
  late String userId;
  late String sig;

  ImGetSigDataModel.fromJson(Map<String, dynamic> json) {
    userId = json['userId'] ?? "";
    sig = json['sig'] ?? "";
  }

  Map<String, dynamic> toJson() {
    final data = <String, dynamic>{};
    data['userId'] = userId;
    data['sig'] = sig;
    return data;
  }
}
